package com.aaa.medicine.controller;

import com.aaa.entity.InventoryLog;
import com.aaa.entity.Purchase;
import com.aaa.entity.PurchaseItem;
import com.aaa.medicine.service.ExamineService;
import com.aaa.medicine.service.IPurchaseService;
import com.aaa.medicine.vo.PurchaseVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("medicine/Examine/")
public class ExamineController {
    @Autowired IPurchaseService iPurchaseService;
    //查询全部，分页，模糊查询
    @GetMapping("getAll")
    public Result<IPage<Purchase>> getAll1(Page page, PurchaseVo purchaseVo){
        IPage<Purchase> all = iPurchaseService.getAll1(page,purchaseVo.getApplyUserName(),purchaseVo.getProviderId());
        return new Result(all);
    }
    //审核通过
    @PostMapping("modification")
    public Result modification(@RequestBody PurchaseVo purchaseVo){
        purchaseVo.setStutas("3");
        iPurchaseService.modification(purchaseVo.getPurchaseId(),purchaseVo.getStutas());
        return new Result(200,"成功");
    }
    //审核不通过
    @PostMapping("Nomodification")
    public Result<Purchase> Nomodification(@RequestBody PurchaseVo purchaseVo){
        purchaseVo.setStutas("4");
        iPurchaseService.modification(purchaseVo.getPurchaseId(),purchaseVo.getStutas());
        return new Result(200,"成功");
    }
//查看详情
    @Autowired

    private ExamineService examineService;
    @PostMapping("examine")
    public Result<List<InventoryLog> >examine(@RequestBody PurchaseVo PurchaseVo){
        List<PurchaseItem> examine = examineService.examine(PurchaseVo.getPurchaseId());
        return new Result(200,null,examine);
    }
}
